// search.js
import { request } from '@/axios/request'
import { ref } from 'vue'

//病友圈的搜索
export function getSearchData(keyWord: any) {
  return request.get('/api/health/user/sickCircle/v1/searchSickCircle', { params: keyWord })
}
//首页搜索
export function getHomeSearch(keyWord: any) {
  return request.get('/api/health/share/v1/homePageSearch', { params: keyWord })
}
//查询视频
export function getVidoData(config: { categoryId: string; page: number; count: number }) {
  const { categoryId, page, count } = config
  return request.get(
    `/api/health/user/video/v1/findVideoVoList?categoryId=${categoryId}&page=${page}&count=${count}`
  )
}
//查看用户身份证信息
export function findUserIdCard(userId: number, sessionId: string) {
  return request({
    url: '/api/health/user/verify/v1/findUserIdCard',
    method: 'GET',
    headers: {
      userId: userId,
      sessionId: sessionId
    }
  })
}
//查询我的被采纳的意见
export function findMyAdoptedCommentList(
  userId: number,
  sessionId: number,
  config: {
    page: number
    count: number
  }
) {
  return request({
    url: '/api/health/user/verify/v1/findMyAdoptedCommentList',
    method: 'GET',
    headers: {
      userId: userId,
      sessionId: sessionId
    },
    params: config
  })
}
//查询我的病友圈帖子的评论列表
export function findMySickCircleCommentList(
  userId: number,
  sessionId: string,
  config: {
    sickCircleId: number
    page: number
    count: number
  }
) {
  return request({
    url: '/api/health/user/sickCircle/verify/v1/findMySickCircleCommentList',
    method: 'GET',
    headers: {
      userId: userId,
      sessionId: sessionId
    },
    params: config
  })
}
//采纳病友圈优秀评论
export function adoptionProposal(
  userId: number,
  sessionId: string,
  data: {
    commentId: number
    sickCircleId: number
  }
) {
  return request({
    url: '/api/health/user/sickCircle/verify/v1/adoptionProposal',
    method: 'PUT',
    headers: {
      userId: userId,
      sessionId: sessionId
    },
    params: data
  })
}
//绑定身份证
export function bindUserIdCard(
  userId: number,
  sessionId: string,
  data: {
    userId: number
    name: string
    sex: string
    nation: string
    birthday: string
    address: string
    idNumber: string
    issueOffice: string
  }
) {
  return request({
    url: '/api/health/user/verify/v1/bindUserIdCard',
    method: 'POST',
    headers: {
      userId: userId,
      sessionId: sessionId,
      'Content-Type': 'application/json'
    },
    data: data
  })
}
//查询我的病友圈帖子的评论列表
export function findMySickCircleList(
  userId: number,
  sessionId: string,
  config: {
    page: number
    count: number
  }
) {
  return request({
    url: '/api/health/user/sickCircle/verify/v1/findMySickCircleList',
    method: 'GET',
    headers: {
      userId: userId,
      sessionId: sessionId
    },
    params: config
  })
}
//查询用户连续签到天数
export function findUserSign(userId: number, sessionId: string) {
  return request({
    url: '/api/health/user/verify/v1/findUserSign',
    method: 'GET',
    headers: {
      userId: userId,
      sessionId: sessionId
    }
  })
}
//查询用户当天是否签到
export function whetherSignToday(userId: number, sessionId: string) {
  return request({
    url: '/api/health/user/verify/v1/whetherSignToday',
    method: 'GET',
    headers: {
      userId: userId,
      sessionId: sessionId
    }
  })
}
//用户签到
export function addSign(userId: number, sessionId: string) {
  return request({
    url: '/api/health/user/verify/v1/addSign',
    method: 'POST',
    headers: {
      userId: userId,
      sessionId: sessionId
    }
  })
}
//购买视频
export function getshopData(userId: number, sessionId: string, data: any) {
  return request({
    url: '/api/health/user/video/verify/v1/videoBuy',
    headers: {
      userId: userId,
      sessionId: sessionId,
      'Content-Type': 'application/json'
    },
    method: 'POST',
    params: data
  })
}
//查询已经购买的视频
export function findUserVideoBuyList(
  userId: number,
  sessionId: string,
  config: { page: number; count: number }
) {
  return request({
    url: '/api/health/user/verify/v1/findUserVideoBuyList',
    method: 'GET',
    headers: {
      userId: userId,
      sessionId: sessionId
    },
    params: config
  })
}
//收藏视频
export function getcollectionData(userId: number, sessionId: string, data: any) {
  return request({
    url: '/api/health/user/video/verify/v1/addUserVideoCollection',
    headers: {
      userId: userId,
      sessionId: sessionId,
      'Content-Type': 'application/json'
    },
    method: 'POST',
    params: data
  })
}
//评论
export function getpingData(userId: number, sessionId: string, data: any) {
  return request({
    url: '/api/health/user/video/verify/v1/addVideoComment',
    headers: {
      userId: userId,
      sessionId: sessionId,
      'Content-Type': 'application/json'
    },
    method: 'POST',
    params: data
  })
}
//绑定银行卡
export function getbindUserBankCard(userId: number, sessionId: string, data: object) {
  return request({
    url: '/api/health/user/verify/v1/bindUserBankCard',
    headers: {
      userId: userId,
      sessionId: sessionId,
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    method: 'POST',
    data: data
  })
}

//查询银行卡信息
export function findUserBankCardByUserId(userId: number, sessionId: string) {
  return request({
    url: '/api/health/user/verify/v1/findUserBankCardByUserId',
    headers: {
      userId: userId,
      sessionId: sessionId
    },
    method: 'GET',
    params: { userId, sessionId }
  })
}

// 我的钱包
export function getUserWallet(config: { userId: number; sessionId: string }) {
  return request.get('/api/health/user/verify/v1/findUserWallet', {
    params: config
  })
}
//添加档案
export function addUserArchives(userId: number, sessionId: string, data: object) {
  return request({
    url: '/api/health/user/verify/v1/addUserArchives',
    headers: {
      userId: userId,
      sessionId: sessionId,
      'Content-Type': 'application/json'
    },
    method: 'POST',
    data: data
  })
}
//查看档案
export function findUserArchives(userId: number, sessionId: number) {
  return request({
    url: '/api/health/user/verify/v1/findUserArchives',
    headers: {
      userId: userId,
      sessionId: sessionId
    },
    method: 'GET'
  })
}
//删除档案
export function deleteUserArchives(userId: number, sessionId: number, archivesId: number) {
  return request({
    url: '/api/health/user/verify/v1/deleteUserArchives',
    headers: {
      userId: userId,
      sessionId: sessionId
    },
    method: 'DELETE',
    params: { archivesId }
  })
}
//编辑档案
export function updateUserArchives(
  userId: number,
  sessionId: string,
  config: {
    archivesId: number
    diseaseMain: string
    diseaseNow: string
    diseaseBefore: string
    treatmentHospitalRecent: string
    treatmentProcess: string
    treatmentStartTime: string
    treatmentEndTime: string
  }
) {
  return request({
    url: '/api/health/user/verify/v1/updateUserArchives',
    method: 'PUT',
    headers: {
      userId: userId,
      sessionId: sessionId,
      'Content-Type': 'application/json'
    },
    data: { config }
  })
}
